<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<!--/*@thymesVar id="retailOrder" type="com.elanfox.spotmall.biz.entity.order.RetailOrderPO"*/-->
<!--/*@thymesVar id="wsOrder" type="com.elanfox.spotmall.biz.entity.order.WsOrderPO"*/-->
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<ul class="nav nav-tabs" th:fragment="retail_order_tab(tabIndex)">
    <li class="active" th:class="${tabIndex==0?'active':''}">
        <a href="order_detail.html" th:href="@{/order/retail/detail(orderId=${retailOrder.orderId})}">基本信息</a>
    </li>
    <li class="" th:class="${tabIndex==1?'active':''}">
        <a href="order_log_list.html" th:href="@{/order/retail/log(orderId=${retailOrder.orderId})}">订单日志</a>
    </li>
</ul>

<ul class="nav nav-tabs" th:fragment="ws_order_tab(tabIndex)">
    <li class="active" th:class="${tabIndex==0?'active':''}">
        <a href="order_detail.html" th:href="@{/order/wholesale/detail(orderId=${wsOrder.orderId})}">基本信息</a>
    </li>
    <li class="" th:class="${tabIndex==1?'active':''}">
        <a href="order_log_list.html" th:href="@{/order/wholesale/log(orderId=${wsOrder.orderId})}">订单日志</a>
    </li>
</ul>

<div th:fragment="retail_order_detail_header" class="animated fadeInRight"
     style="padding:0 6px;position:fixed;width:100%;top: 0;z-index:101;">
    <input type="hidden" id="orderId" th:value="${retailOrder.orderId}"/>
    <div class="col-lg-12">
        <div class="ibox float-e-margins" style="margin-bottom:0;">
            <div class="ibox-title" style="padding: 14px 15px 11px;">
                <div class="form-inline">
                    <div class="form-group m-r-sm">
                        <label style="font-size: 17px; margin-top: 5px;">
                            订单-
                            <span th:text="${retailOrder.orderId}">20170110095434456651</span>
                            <span class="m-l-xs" th:text="${retailOrder.deliverStatus.desc}"
                                  th:classappend="${retailOrder.deliverStatusClass()}"
                                  style="font-size:13px;font-weight:normal">待发货</span>
                        </label>
                    </div>
                    <div class="form-group m-r-sm" style="float: right; ">
                        <button onclick="deliverHandler.deliverModal();" th:if="${retailOrder.deliverStatus.code==0}"
                                type="button" class="btn btn-primary btn-sm">发货
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="deliver_modal" style="display: none;">
        <div class="form-horizontal" style="width: 479px;height: 100px">
            <div class="form-group">
                <label class="col-sm-4 control-label">*快递单号：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control input-sm" id="deliver_expressNo" placeholder="快递单号"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-4 control-label">*快递公司：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control input-sm" id="deliver_expressCompany" placeholder="快递公司"/>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript" th:inline="javascript">
        const apiUri = /*[[@{/order/retail/deliver}]]*/  "";
    </script>

    <script type="text/javascript">
        var deliverHandler = {
            deliverModal: function () {
                deliverModal.show()
            },
            deliver: function () {
                let orderId = $("#orderId").val();
                let expressNo = $.trim($("#deliver_expressNo").val());
                let expressCompany = $.trim($("#deliver_expressCompany").val());

                if (expressNo.length === 0) {
                    hot.tip.msg("请输入快递单号");
                    return;
                }
                if (expressCompany.length === 0) {
                    hot.tip.msg("请输入快递公司");
                    return;
                }
                let requestData = {
                    orderId: orderId,
                    expressNo: expressNo,
                    expressCompany: expressCompany
                };

                hot.ajax(apiUri + "/deliver", requestData, function (apiResult) {
                    if (apiResult.resultCode === 2000) {
                        hot.tip.success("发货成功", function () {
                            window.location.reload();
                        })
                    } else {
                        hot.tip.error("发货失败--" + apiResult.resultMsg);
                    }
                }, function () {
                }, "post")
            }
        }
    </script>
</div>

<div th:fragment="ws_order_detail_header" class="animated fadeInRight"
     style="padding:0 6px;position:fixed;width:100%;top: 0;z-index:101;">
    <div class="col-lg-12">
        <div class="ibox float-e-margins" style="margin-bottom:0;">
            <div class="ibox-title" style="padding: 14px 15px 11px;">
                <div class="form-inline">
                    <div class="form-group m-r-sm">
                        <label style="font-size: 17px; margin-top: 5px;">
                            订单-
                            <span th:text="${wsOrder.orderId}">20170110095434456651</span>
                            <span class="m-l-xs" th:text="${wsOrder.sellStatus.desc}"
                                  th:classappend="${wsOrder.sellStatusClass()}"
                                  style="font-size:13px;font-weight:normal">持仓中</span>
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>